<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Unsafe #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE NoImplicitPrelude, MagicHash, UnboxedTuples, RankNTypes #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# OPTIONS_HADDOCK not-home #-}</span><span>
</span><span id="line-4"></span><span>
</span><span id="line-5"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Module      :  GHC.ST</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow, 1992-2002</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- License     :  see libraries/base/LICENSE</span><span>
</span><span id="line-10"></span><span class="hs-comment">--</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Maintainer  :  cvs-ghc@haskell.org</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Stability   :  internal</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Portability :  non-portable (GHC Extensions)</span><span>
</span><span id="line-14"></span><span class="hs-comment">--</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- The 'ST' Monad.</span><span>
</span><span id="line-16"></span><span class="hs-comment">--</span><span>
</span><span id="line-17"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.ST</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-20"></span><span>        </span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier">ST</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ST.html#STret"><span class="hs-identifier">STret</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ST.html#STRep"><span class="hs-identifier">STRep</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>        </span><span class="annot"><a href="GHC.ST.html#runST"><span class="hs-identifier">runST</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>
</span><span id="line-23"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Unsafe functions</span></span><span>
</span><span id="line-24"></span><span>        </span><span class="annot"><a href="GHC.ST.html#liftST"><span class="hs-identifier">liftST</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ST.html#unsafeInterleaveST"><span class="hs-identifier">unsafeInterleaveST</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.ST.html#unsafeDupableInterleaveST"><span class="hs-identifier">unsafeDupableInterleaveST</span></a></span><span>
</span><span id="line-25"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-26"></span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Show.html"><span class="hs-identifier">GHC.Show</span></a></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Control.Monad.Fail.html"><span class="hs-identifier">Control.Monad.Fail</span></a></span><span>
</span><span id="line-30"></span><span>
</span><span id="line-31"></span><span class="hs-keyword">default</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-32"></span><span>
</span><span id="line-33"></span><span class="hs-comment">-- The 'ST' monad proper.  By default the monad is strict;</span><span>
</span><span id="line-34"></span><span class="hs-comment">-- too many people got bitten by space leaks when it was lazy.</span><span>
</span><span id="line-35"></span><span>
</span><span id="line-36"></span><span class="hs-comment">-- | The strict 'ST' monad.</span><span>
</span><span id="line-37"></span><span class="hs-comment">-- The 'ST' monad allows for destructive updates, but is escapable (unlike IO).</span><span>
</span><span id="line-38"></span><span class="hs-comment">-- A computation of type @'ST' s a@ returns a value of type @a@, and</span><span>
</span><span id="line-39"></span><span class="hs-comment">-- execute in &quot;thread&quot; @s@. The @s@ parameter is either</span><span>
</span><span id="line-40"></span><span class="hs-comment">--</span><span>
</span><span id="line-41"></span><span class="hs-comment">-- * an uninstantiated type variable (inside invocations of 'runST'), or</span><span>
</span><span id="line-42"></span><span class="hs-comment">--</span><span>
</span><span id="line-43"></span><span class="hs-comment">-- * 'RealWorld' (inside invocations of 'Control.Monad.ST.stToIO').</span><span>
</span><span id="line-44"></span><span class="hs-comment">--</span><span>
</span><span id="line-45"></span><span class="hs-comment">-- It serves to keep the internal states of different invocations</span><span>
</span><span id="line-46"></span><span class="hs-comment">-- of 'runST' separate from each other and from invocations of</span><span>
</span><span id="line-47"></span><span class="hs-comment">-- 'Control.Monad.ST.stToIO'.</span><span>
</span><span id="line-48"></span><span class="hs-comment">--</span><span>
</span><span id="line-49"></span><span class="hs-comment">-- The '&gt;&gt;=' and '&gt;&gt;' operations are strict in the state (though not in</span><span>
</span><span id="line-50"></span><span class="hs-comment">-- values stored in the state).  For example,</span><span>
</span><span id="line-51"></span><span class="hs-comment">--</span><span>
</span><span id="line-52"></span><span class="hs-comment">-- @'runST' (writeSTRef _|_ v &gt;&gt;= f) = _|_@</span><span>
</span><span id="line-53"></span><span class="hs-keyword">newtype</span><span> </span><span id="ST"><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-var">ST</span></a></span></span><span> </span><span id="local-6989586621679501604"><span class="annot"><a href="#local-6989586621679501604"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span id="local-6989586621679501603"><span class="annot"><a href="#local-6989586621679501603"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="ST"><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-var">ST</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ST.html#STRep"><span class="hs-identifier hs-type">STRep</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501604"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501603"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-54"></span><span class="hs-keyword">type</span><span> </span><span id="STRep"><span class="annot"><a href="GHC.ST.html#STRep"><span class="hs-identifier hs-var">STRep</span></a></span></span><span> </span><span id="local-6989586621679501495"><span class="annot"><a href="#local-6989586621679501495"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span id="local-6989586621679501494"><span class="annot"><a href="#local-6989586621679501494"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#State%23"><span class="hs-identifier hs-type">State#</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501495"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#State%23"><span class="hs-identifier hs-type">State#</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501495"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621679501494"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-55"></span><span>
</span><span id="line-56"></span><span class="hs-comment">-- | @since 2.01</span><span>
</span><span id="line-57"></span><span id="local-6989586621679501608"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679501491"><span class="annot"><a href="GHC.Base.html#Functor"><span class="hs-identifier hs-type">Functor</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501608"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-58"></span><span>    </span><span id="local-6989586621679501489"><span class="annot"><span class="annottext">fmap :: forall a b. (a -&gt; b) -&gt; ST s a -&gt; ST s b
</span><a href="GHC.Base.html#fmap"><span class="hs-identifier hs-var hs-var hs-var hs-var">fmap</span></a></span></span><span> </span><span id="local-6989586621679501488"><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679501488"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span id="local-6989586621679501487"><span class="annot"><span class="annottext">STRep s a
</span><a href="#local-6989586621679501487"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STRep s b -&gt; ST s b
forall s a. STRep s a -&gt; ST s a
</span><a href="GHC.ST.html#ST"><span class="hs-identifier hs-var">ST</span></a></span><span> </span><span class="annot"><span class="annottext">(STRep s b -&gt; ST s b) -&gt; STRep s b -&gt; ST s b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679501486"><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679501486"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-59"></span><span>      </span><span class="hs-keyword">case</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">STRep s a
</span><a href="#local-6989586621679501487"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679501486"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(#</span><span> </span><span id="local-6989586621679501485"><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679501485"><span class="hs-identifier hs-var">new_s</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679501484"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679501484"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-60"></span><span>      </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679501485"><span class="hs-identifier hs-var">new_s</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679501488"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679501484"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-special">}</span></span><span>
</span><span id="line-61"></span><span>
</span><span id="line-62"></span><span class="hs-comment">-- | @since 4.4.0.0</span><span>
</span><span id="line-63"></span><span id="local-6989586621679501588"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679501476"><span class="annot"><a href="GHC.Base.html#Applicative"><span class="hs-identifier hs-type">Applicative</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501588"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-64"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.Base.html#pure"><span class="hs-pragma hs-type">pure</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-65"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="hs-pragma">(</span><span class="hs-pragma">*&gt;</span><span class="hs-pragma">)</span><span>   </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-66"></span><span>    </span><span id="local-6989586621679501474"><span class="annot"><span class="annottext">pure :: forall a. a -&gt; ST s a
</span><a href="GHC.Base.html#pure"><span class="hs-identifier hs-var hs-var hs-var hs-var">pure</span></a></span></span><span> </span><span id="local-6989586621679501473"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679501473"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STRep s a -&gt; ST s a
forall s a. STRep s a -&gt; ST s a
</span><a href="GHC.ST.html#ST"><span class="hs-identifier hs-var">ST</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679501472"><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679501472"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679501472"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679501473"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-special">#)</span><span class="hs-special">)</span><span>
</span><span id="line-67"></span><span>    </span><span id="local-6989586621679501470"><span class="annot"><span class="annottext">ST s a
</span><a href="#local-6989586621679501470"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679501469"><span class="annot"><span class="annottext">*&gt; :: forall a b. ST s a -&gt; ST s b -&gt; ST s b
</span><a href="GHC.Base.html#%2A%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">*&gt;</span></a></span></span><span> </span><span id="local-6989586621679501468"><span class="annot"><span class="annottext">ST s b
</span><a href="#local-6989586621679501468"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ST s a
</span><a href="#local-6989586621679501470"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">ST s a -&gt; (a -&gt; ST s b) -&gt; ST s b
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ST s b
</span><a href="#local-6989586621679501468"><span class="hs-identifier hs-var">k</span></a></span><span>
</span><span id="line-68"></span><span>    </span><span id="local-6989586621679501466"><span class="annot"><span class="annottext">&lt;*&gt; :: forall a b. ST s (a -&gt; b) -&gt; ST s a -&gt; ST s b
</span><a href="GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">(&lt;*&gt;)</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ST s (a -&gt; b) -&gt; ST s a -&gt; ST s b
forall (m :: * -&gt; *) a b. Monad m =&gt; m (a -&gt; b) -&gt; m a -&gt; m b
</span><a href="GHC.Base.html#ap"><span class="hs-identifier hs-var">ap</span></a></span><span>
</span><span id="line-69"></span><span>    </span><span id="local-6989586621679501463"><span class="annot"><span class="annottext">liftA2 :: forall a b c. (a -&gt; b -&gt; c) -&gt; ST s a -&gt; ST s b -&gt; ST s c
</span><a href="GHC.Base.html#liftA2"><span class="hs-identifier hs-var hs-var hs-var hs-var">liftA2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(a -&gt; b -&gt; c) -&gt; ST s a -&gt; ST s b -&gt; ST s c
forall (m :: * -&gt; *) a1 a2 r.
Monad m =&gt;
(a1 -&gt; a2 -&gt; r) -&gt; m a1 -&gt; m a2 -&gt; m r
</span><a href="GHC.Base.html#liftM2"><span class="hs-identifier hs-var">liftM2</span></a></span></span><span>
</span><span id="line-70"></span><span>
</span><span id="line-71"></span><span class="hs-comment">-- | @since 2.01</span><span>
</span><span id="line-72"></span><span id="local-6989586621679501586"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679501455"><span class="annot"><a href="GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501586"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-73"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="hs-pragma">(</span><span class="hs-pragma">&gt;&gt;=</span><span class="hs-pragma">)</span><span>  </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-74"></span><span>    </span><span id="local-6989586621679501452"><span class="annot"><span class="annottext">&gt;&gt; :: forall a b. ST s a -&gt; ST s b -&gt; ST s b
</span><a href="GHC.Base.html#%3E%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">(&gt;&gt;)</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ST s a -&gt; ST s b -&gt; ST s b
forall (f :: * -&gt; *) a b. Applicative f =&gt; f a -&gt; f b -&gt; f b
</span><a href="GHC.Base.html#%2A%3E"><span class="hs-operator hs-var">(*&gt;)</span></a></span><span>
</span><span id="line-75"></span><span>    </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span id="local-6989586621679501451"><span class="annot"><span class="annottext">STRep s a
</span><a href="#local-6989586621679501451"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679501450"><span class="annot"><span class="annottext">&gt;&gt;= :: forall a b. ST s a -&gt; (a -&gt; ST s b) -&gt; ST s b
</span><a href="GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var hs-var hs-var hs-var">&gt;&gt;=</span></a></span></span><span> </span><span id="local-6989586621679501449"><span class="annot"><span class="annottext">a -&gt; ST s b
</span><a href="#local-6989586621679501449"><span class="hs-identifier hs-var">k</span></a></span></span><span>
</span><span id="line-76"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STRep s b -&gt; ST s b
forall s a. STRep s a -&gt; ST s a
</span><a href="GHC.ST.html#ST"><span class="hs-identifier hs-var">ST</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679501448"><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679501448"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-77"></span><span>        </span><span class="hs-keyword">case</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">STRep s a
</span><a href="#local-6989586621679501451"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679501448"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(#</span><span> </span><span id="local-6989586621679501447"><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679501447"><span class="hs-identifier hs-var">new_s</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679501446"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679501446"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-78"></span><span>        </span><span class="hs-keyword">case</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; ST s b
</span><a href="#local-6989586621679501449"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679501446"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span id="local-6989586621679501445"><span class="annot"><span class="annottext">STRep s b
</span><a href="#local-6989586621679501445"><span class="hs-identifier hs-var">k2</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-79"></span><span>        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">STRep s b
</span><a href="#local-6989586621679501445"><span class="hs-identifier hs-var">k2</span></a></span><span> </span><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679501447"><span class="hs-identifier hs-var">new_s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span class="hs-special">}</span><span class="hs-special">)</span></span><span>
</span><span id="line-80"></span><span>
</span><span id="line-81"></span><span class="hs-comment">-- | @since 4.11.0.0</span><span>
</span><span id="line-82"></span><span id="local-6989586621679501558"><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="Control.Monad.Fail.html#MonadFail"><span class="hs-identifier hs-type">MonadFail</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501558"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-83"></span><span>    </span><span id="local-6989586621679501439"><span class="annot"><span class="annottext">fail :: forall a. String -&gt; ST s a
</span><a href="Control.Monad.Fail.html#fail"><span class="hs-identifier hs-var hs-var hs-var hs-var">fail</span></a></span></span><span> </span><span id="local-6989586621679501438"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679501438"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; ST s a
forall a. String -&gt; a
</span><a href="GHC.Err.html#errorWithoutStackTrace"><span class="hs-identifier hs-var">errorWithoutStackTrace</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679501438"><span class="hs-identifier hs-var">s</span></a></span></span><span>
</span><span id="line-84"></span><span>
</span><span id="line-85"></span><span class="hs-comment">-- | @since 4.11.0.0</span><span>
</span><span id="line-86"></span><span id="local-6989586621679501550"><span id="local-6989586621679501551"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679501432"><span id="local-6989586621679501434"><span class="annot"><a href="GHC.Base.html#Semigroup"><span class="hs-identifier hs-type">Semigroup</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501551"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#Semigroup"><span class="hs-identifier hs-type">Semigroup</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501550"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501551"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-87"></span><span>    </span><span id="local-6989586621679501428"><span class="annot"><span class="annottext">&lt;&gt; :: ST s a -&gt; ST s a -&gt; ST s a
</span><a href="GHC.Base.html#%3C%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">(&lt;&gt;)</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(a -&gt; a -&gt; a) -&gt; ST s a -&gt; ST s a -&gt; ST s a
forall (f :: * -&gt; *) a b c.
Applicative f =&gt;
(a -&gt; b -&gt; c) -&gt; f a -&gt; f b -&gt; f c
</span><a href="GHC.Base.html#liftA2"><span class="hs-identifier hs-var">liftA2</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; a -&gt; a
forall a. Semigroup a =&gt; a -&gt; a -&gt; a
</span><a href="GHC.Base.html#%3C%3E"><span class="hs-operator hs-var">(&lt;&gt;)</span></a></span></span></span><span>
</span><span id="line-88"></span><span>
</span><span id="line-89"></span><span class="hs-comment">-- | @since 4.11.0.0</span><span>
</span><span id="line-90"></span><span id="local-6989586621679501547"><span id="local-6989586621679501548"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679501421"><span id="local-6989586621679501423"><span class="annot"><a href="GHC.Base.html#Monoid"><span class="hs-identifier hs-type">Monoid</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501548"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Base.html#Monoid"><span class="hs-identifier hs-type">Monoid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501547"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501548"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-91"></span><span>    </span><span id="local-6989586621679501417"><span class="annot"><span class="annottext">mempty :: ST s a
</span><a href="GHC.Base.html#mempty"><span class="hs-identifier hs-var hs-var hs-var hs-var">mempty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; ST s a
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">a
forall a. Monoid a =&gt; a
</span><a href="GHC.Base.html#mempty"><span class="hs-identifier hs-var">mempty</span></a></span></span></span><span>
</span><span id="line-92"></span><span>
</span><span id="line-93"></span><span class="hs-keyword">data</span><span> </span><span id="STret"><span class="annot"><a href="GHC.ST.html#STret"><span class="hs-identifier hs-var">STret</span></a></span></span><span> </span><span id="local-6989586621679501541"><span class="annot"><a href="#local-6989586621679501541"><span class="hs-identifier hs-type">s</span></a></span></span><span> </span><span id="local-6989586621679501540"><span class="annot"><a href="#local-6989586621679501540"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="STret"><span class="annot"><a href="GHC.ST.html#STret"><span class="hs-identifier hs-var">STret</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#State%23"><span class="hs-identifier hs-type">State#</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501541"><span class="hs-identifier hs-type">s</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="#local-6989586621679501540"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-94"></span><span>
</span><span id="line-95"></span><span class="hs-comment">-- liftST is useful when we want a lifted result from an ST computation.</span><span>
</span><span id="line-96"></span><span id="local-6989586621679501545"><span id="local-6989586621679501546"><span class="annot"><a href="GHC.ST.html#liftST"><span class="hs-identifier hs-type">liftST</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501546"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501545"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#State%23"><span class="hs-identifier hs-type">State#</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501546"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.ST.html#STret"><span class="hs-identifier hs-type">STret</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501546"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501545"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-97"></span><span id="liftST"><span class="annot"><span class="annottext">liftST :: forall s a. ST s a -&gt; State# s -&gt; STret s a
</span><a href="GHC.ST.html#liftST"><span class="hs-identifier hs-var hs-var">liftST</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span id="local-6989586621679501415"><span class="annot"><span class="annottext">STRep s a
</span><a href="#local-6989586621679501415"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679501414"><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679501414"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">STRep s a
</span><a href="#local-6989586621679501415"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679501414"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">(#</span><span> </span><span id="local-6989586621679501413"><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679501413"><span class="hs-identifier hs-var">s'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679501412"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679501412"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">State# s -&gt; a -&gt; STret s a
forall s a. State# s -&gt; a -&gt; STret s a
</span><a href="GHC.ST.html#STret"><span class="hs-identifier hs-var">STret</span></a></span><span> </span><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679501413"><span class="hs-identifier hs-var">s'</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679501412"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-98"></span><span>
</span><span id="line-99"></span><span id="local-6989586621679501539"><span class="annot"><a href="GHC.ST.html#noDuplicateST"><span class="hs-identifier hs-type">noDuplicateST</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501539"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-100"></span><span id="noDuplicateST"><span class="annot"><span class="annottext">noDuplicateST :: forall s. ST s ()
</span><a href="GHC.ST.html#noDuplicateST"><span class="hs-identifier hs-var hs-var">noDuplicateST</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STRep s () -&gt; ST s ()
forall s a. STRep s a -&gt; ST s a
</span><a href="GHC.ST.html#ST"><span class="hs-identifier hs-var">ST</span></a></span><span> </span><span class="annot"><span class="annottext">(STRep s () -&gt; ST s ()) -&gt; STRep s () -&gt; ST s ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679501410"><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679501410"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">State# s -&gt; State# s
forall d. State# d -&gt; State# d
</span><a href="../../ghc-prim/src/GHC.Prim.html#noDuplicate%23"><span class="hs-identifier hs-var">noDuplicate#</span></a></span><span> </span><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679501410"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-101"></span><span>
</span><span id="line-102"></span><span class="hs-comment">-- | 'unsafeInterleaveST' allows an 'ST' computation to be deferred</span><span>
</span><span id="line-103"></span><span class="hs-comment">-- lazily.  When passed a value of type @ST a@, the 'ST' computation will</span><span>
</span><span id="line-104"></span><span class="hs-comment">-- only be performed when the value of the @a@ is demanded.</span><span>
</span><span id="line-105"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.ST.html#unsafeInterleaveST"><span class="hs-pragma hs-type">unsafeInterleaveST</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-106"></span><span id="local-6989586621679501535"><span id="local-6989586621679501536"><span class="annot"><a href="GHC.ST.html#unsafeInterleaveST"><span class="hs-identifier hs-type">unsafeInterleaveST</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501536"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501535"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501536"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501535"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-107"></span><span id="unsafeInterleaveST"><span class="annot"><span class="annottext">unsafeInterleaveST :: forall s a. ST s a -&gt; ST s a
</span><a href="GHC.ST.html#unsafeInterleaveST"><span class="hs-identifier hs-var hs-var">unsafeInterleaveST</span></a></span></span><span> </span><span id="local-6989586621679501408"><span class="annot"><span class="annottext">ST s a
</span><a href="#local-6989586621679501408"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ST s a -&gt; ST s a
forall s a. ST s a -&gt; ST s a
</span><a href="GHC.ST.html#unsafeDupableInterleaveST"><span class="hs-identifier hs-var">unsafeDupableInterleaveST</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ST s ()
forall s. ST s ()
</span><a href="GHC.ST.html#noDuplicateST"><span class="hs-identifier hs-var">noDuplicateST</span></a></span><span> </span><span class="annot"><span class="annottext">ST s () -&gt; ST s a -&gt; ST s a
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">ST s a
</span><a href="#local-6989586621679501408"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-108"></span><span>
</span><span id="line-109"></span><span class="hs-comment">-- | 'unsafeDupableInterleaveST' allows an 'ST' computation to be deferred</span><span>
</span><span id="line-110"></span><span class="hs-comment">-- lazily.  When passed a value of type @ST a@, the 'ST' computation will</span><span>
</span><span id="line-111"></span><span class="hs-comment">-- only be performed when the value of the @a@ is demanded.</span><span>
</span><span id="line-112"></span><span class="hs-comment">--</span><span>
</span><span id="line-113"></span><span class="hs-comment">-- The computation may be performed multiple times by different threads,</span><span>
</span><span id="line-114"></span><span class="hs-comment">-- possibly at the same time. To prevent this, use 'unsafeInterleaveST' instead.</span><span>
</span><span id="line-115"></span><span class="hs-comment">--</span><span>
</span><span id="line-116"></span><span class="hs-comment">-- @since 4.11</span><span>
</span><span id="line-117"></span><span class="hs-pragma">{-# NOINLINE</span><span> </span><span class="annot"><a href="GHC.ST.html#unsafeDupableInterleaveST"><span class="hs-pragma hs-type">unsafeDupableInterleaveST</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-118"></span><span class="hs-comment">-- See Note [unsafeDupableInterleaveIO should not be inlined]</span><span>
</span><span id="line-119"></span><span class="hs-comment">-- in GHC.IO.Unsafe</span><span>
</span><span id="line-120"></span><span id="local-6989586621679501406"><span id="local-6989586621679501407"><span class="annot"><a href="GHC.ST.html#unsafeDupableInterleaveST"><span class="hs-identifier hs-type">unsafeDupableInterleaveST</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501407"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501406"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501407"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501406"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-121"></span><span id="unsafeDupableInterleaveST"><span class="annot"><span class="annottext">unsafeDupableInterleaveST :: forall s a. ST s a -&gt; ST s a
</span><a href="GHC.ST.html#unsafeDupableInterleaveST"><span class="hs-identifier hs-var hs-var">unsafeDupableInterleaveST</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span id="local-6989586621679501405"><span class="annot"><span class="annottext">STRep s a
</span><a href="#local-6989586621679501405"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STRep s a -&gt; ST s a
forall s a. STRep s a -&gt; ST s a
</span><a href="GHC.ST.html#ST"><span class="hs-identifier hs-var">ST</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679501404"><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679501404"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-122"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-123"></span><span>        </span><span id="local-6989586621679501403"><span class="annot"><span class="annottext">r :: a
</span><a href="#local-6989586621679501403"><span class="hs-identifier hs-var hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">STRep s a
</span><a href="#local-6989586621679501405"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679501404"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">State# s
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679501402"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679501402"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679501402"><span class="hs-identifier hs-var">res</span></a></span><span>
</span><span id="line-124"></span><span>    </span><span class="hs-keyword">in</span><span>
</span><span id="line-125"></span><span>    </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679501404"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679501403"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-126"></span><span>  </span><span class="hs-special">)</span><span>
</span><span id="line-127"></span><span>
</span><span id="line-128"></span><span class="hs-comment">-- | @since 2.01</span><span>
</span><span id="line-129"></span><span id="local-6989586621679501527"><span id="local-6989586621679501528"><span class="hs-keyword">instance</span><span>  </span><span id="local-6989586621679501399"><span class="annot"><a href="GHC.Show.html#Show"><span class="hs-identifier hs-type">Show</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501528"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501527"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-130"></span><span>    </span><span id="local-6989586621679501396"><span class="annot"><span class="annottext">showsPrec :: Int -&gt; ST s a -&gt; ShowS
</span><a href="GHC.Show.html#showsPrec"><span class="hs-identifier hs-var hs-var hs-var hs-var">showsPrec</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">ST s a
</span><span class="hs-identifier">_</span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
</span><a href="GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&lt;&lt;ST action&gt;&gt;&quot;</span></span><span>
</span><span id="line-131"></span><span>    </span><span id="local-6989586621679501392"><span class="annot"><span class="annottext">showList :: [ST s a] -&gt; ShowS
</span><a href="GHC.Show.html#showList"><span class="hs-identifier hs-var hs-var hs-var hs-var">showList</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(ST s a -&gt; ShowS) -&gt; [ST s a] -&gt; ShowS
forall a. (a -&gt; ShowS) -&gt; [a] -&gt; ShowS
</span><a href="GHC.Show.html#showList__"><span class="hs-identifier hs-var">showList__</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; ST s a -&gt; ShowS
forall a. Show a =&gt; Int -&gt; a -&gt; ShowS
</span><a href="GHC.Show.html#showsPrec"><span class="hs-identifier hs-var">showsPrec</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span></span></span><span>
</span><span id="line-132"></span><span>
</span><span id="line-133"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="GHC.ST.html#runST"><span class="hs-pragma hs-type">runST</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-134"></span><span class="hs-comment">-- | Return the value computed by a state thread.</span><span>
</span><span id="line-135"></span><span class="hs-comment">-- The @forall@ ensures that the internal state used by the 'ST'</span><span>
</span><span id="line-136"></span><span class="hs-comment">-- computation is inaccessible to the rest of the program.</span><span>
</span><span id="line-137"></span><span id="local-6989586621679501524"><span class="annot"><a href="GHC.ST.html#runST"><span class="hs-identifier hs-type">runST</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679501525"><span class="annot"><a href="#local-6989586621679501525"><span class="hs-identifier hs-type">s</span></a></span></span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501525"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679501524"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679501524"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-138"></span><span id="runST"><span class="annot"><span class="annottext">runST :: forall a. (forall s. ST s a) -&gt; a
</span><a href="GHC.ST.html#runST"><span class="hs-identifier hs-var hs-var">runST</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span id="local-6989586621679501389"><span class="annot"><span class="annottext">STRep RealWorld a
</span><a href="#local-6989586621679501389"><span class="hs-identifier hs-var">st_rep</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">STRep RealWorld a -&gt; (# State# RealWorld, a #)
forall o. (State# RealWorld -&gt; o) -&gt; o
</span><a href="../../ghc-prim/src/GHC.Magic.html#runRW%23"><span class="hs-identifier hs-var">runRW#</span></a></span><span> </span><span class="annot"><span class="annottext">STRep RealWorld a
</span><a href="#local-6989586621679501389"><span class="hs-identifier hs-var">st_rep</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679501388"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679501388"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679501388"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-139"></span><span class="hs-comment">-- See Note [Definition of runRW#] in GHC.Magic</span><span>
</span><span id="line-140"></span></pre></body></html>